<?php
include_once(_CORE_PATH. 'router/router_prototype.php');
class router_admin_http extends router_prototype
{
	public function DetectCtrlAndAction(array $elements = array())
	{
		$ctrlName = $actionName = '';
		
		if ($elements['ctrl']) $ctrlName = $elements['ctrl'];
		if ($elements['action']) $actionName = $elements['action'];
		
		return array($ctrlName, $actionName);
	}

	/**
	 * определяем поведение controller & action
	 * 
	 */
	public function Build(array &$elements = array())
	{
		$url = array();
		
		$url = $this->DetectCtrlAndAction($elements);
		unset($elements['ctrl']);
		unset($elements['action']);		
		
		return $url;
	}
	
	public function Parse(array &$segments = array())
	{
		$elements = array();
		if (isset($segments[0]))
		{
			$elements['ctrl'] = $segments[0];
			array_shift($segments);
		}
		
		if (isset($segments[0]))
		{
			$elements['action'] = $segments[0];
			array_shift($segments);
		}	

		return $elements;
	}
	
	/* ------------ роутеры контроллеров -----------------*/
	public function BuildStructure(array &$elements = array())
	{
		return array();
	}
}